<template>
  <div class="page page-role">
    <!--    <c-content :pagination="false">-->
    <!--      <el-form slot="search" :inline="true" class="search-form" label-width="80px" @submit.native.prevent>-->
    <!--        <el-form-item class="search-btn">-->
    <!--          <el-button v-waves type="primary" @click="openXM" size="mini">新增</el-button>-->
    <!--        </el-form-item>-->
    <!--        <el-form-item label="角色名称">-->
    <!--          <el-input v-model="form.role_name" placeholder="请输入角色名称" clearable @keyup.enter.native="getList()" @clear="getList()" />-->
    <!--        </el-form-item>-->
    <!--      </el-form>-->
    <!--      <el-table-->
    <!--          slot="table"-->
    <!--          ref="multipleTable"-->
    <!--          v-loading="tab_loading"-->
    <!--          width="100%"-->
    <!--          border-->
    <!--          :data="dataList"-->
    <!--          class="expand&#45;&#45;table">-->
    <!--        <el-table-column align="center" prop="role_name" label="角色名称" />-->
    <!--        <el-table-column align="center" prop="create_time" label="生产线" />-->
    <!--        <el-table-column align="center" prop="create_time" label="创建时间" />-->
    <!--        <el-table-column align="center" prop="remark" label="备注" />-->
    <!--        <el-table-column align="center" label="状态">-->
    <!--          <template slot-scope="scope">-->
    <!--            <el-tag v-if="scope.row.status == 'normal'" size="mini" type="success">正常</el-tag>-->
    <!--            <el-tag v-if="scope.row.status == 'hidden'" size="mini" type="danger">禁用</el-tag>-->
    <!--          </template>-->
    <!--        </el-table-column>-->
    <!--        <el-table-column align="center" label="操作">-->
    <!--          <template slot-scope="scope">-->
    <!--            <c-button>-->
    <!--              <span @click="openXM(scope.row)">编辑</span>-->
    <!--              <span @click="handleDel(scope.row)" class="danger">删除</span>-->
    <!--            </c-button>-->
    <!--          </template>-->
    <!--        </el-table-column>-->
    <!--      </el-table>-->
    <!--    </c-content>-->
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import { getRoleList, deleteRole } from '@/api/user'
import AddEdit from './XM/AddEditTargetSet'
export default {
  components: {
    // CContent: () => import('@/components/CContent'),
    // CButton: () => import('@/components/CButton')
  },
  computed: {
    ...mapGetters(['btn_permission']),
  },
  props: {
    layerid: {
      default: 0,
    },
  },
  data() {
    return {
      tab_loading: false,
      form: {},
      dataList: [],
    }
  },
  created() {
    //this.$getReset();
    // this.getList();
  },
  methods: {
    /* 查询 */
    async getList() {
      const obj = JSON.parse(JSON.stringify(this.form))
      this.tab_loading = true
      const { data } = await getRoleList(obj)
      this.tab_loading = false
      this.dataList = data.list
    },
    /* 删除角色 */
    handleDel(row) {
      this.$confirm('确认删除此角色?', '提示', {
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(async () => {
          const { code } = await deleteRole({
            admin_role_id: row.admin_role_id,
          })

          //  if (code === 200) {
          this.$message({ message: '删除成功', type: 'success' })
          this.getList()
          // }
        })
        .catch(() => {})
    },
    /* 添加和编辑 */
    openXM(row) {
      this.$layer.iframe({
        shadeClose: false,
        content: {
          content: AddEdit,
          parent: this,
          data: { row: row },
        },
        maxmin: true,
        area: ['600px', '500px'],
        title: row.admin_role_id ? '编辑角色' : '添加角色',
      })
    },
  },
}
</script>

<style lang="scss" scoped></style>
